/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package AplManager.controller;
import AplManager.views.*;
import AplManager.models.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
 *
 * @author user
 */
public class MenuController {
     //private TableDisplayy view;
    // private EnterNewForm view;
    private Menu view;
    private ActionListener actionListener;
    
    public MenuController(Menu view){
       this.view  = view;
    }
    
    public void control(){        
        actionListener = new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) { 
                  if(e.getSource().equals(view.getNewTeam())){
                  //EnterNewForm entry = new EnterNewForm();
                  EnterNewForm eView = new EnterNewForm ();
                  eView.setVisible(true);
                  EnterNewFormController  control = new   EnterNewFormController(eView);
                  control.control();
                 view.setVisible(false);
                  }
                   if(e.getSource().equals(view.getExistingTeam())){
                  //EnterNewForm entry = new EnterNewForm();
                      
                       view.setVisible(false);
                  EnterForm entry = new EnterForm();
               
                EnterFormController control = new EnterFormController(entry);
                 entry.setVisible(true);
                control.control();
              // view.setVisible(false);
                 //DBcontroller dbControl = new DBcontroller(null,null);
                 //dbControl.initialize();
                 //dbControl.setTeams();
                
                  }
                  
              }
        };                
        view.getNewTeam().addActionListener(actionListener);
         view.getExistingTeam().addActionListener(actionListener);
    }
}
